<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>供需对接服务系统--项目（内部）编辑页面</title>
    <!--公用样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/comment.css"/>
    <!--页面样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/supplier/common/css/style.css"/>
    <!--Layui-->
    <link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all"/>
    <!--extended-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/extended.css"/>
    <!--公用样式JS-->
    <script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.js" charset="utf-8"></script>

    <script type="text/javascript" src="${re.contextPath}/plugin/supplier/common/js/tel.js" charset="utf-8"></script>
</head>
<style>
    .Right {
        width: 100%;
        overflow-y: scroll;
    }

    .release ul:nth-child(2) li label {
        width: 28%;
    }

    .release ul:first-child li label {
        width: 23%;
    }

    .release .address, .personnel .address {
        width: 65%;
    }

    .connected, .detailXm, .profileList, .proDetail, .change, .showResult {
        position: absolute !important;
        width: 600px !important;
        padding: 20px !important;
        top: 0px;
    !important;
        left: 50% !important;
        transform: translate(-50%, -50%);
    }

</style>

<body>
<!--头部-->
<header class="whitebg"></header>
<!--容器-->
<div class="container clearfix">

    <!--占位-->
    <!--右侧内容-->
    <div class="Right fr mt50 whitebg">

        <form class="layui-form" id="myForm">
            <input id="supAcceptId" name="supAcceptId" type="hidden" value="${supAcceptId}">
            <input id="projectType" type="hidden" value="${project.projectType}">
            <input id="publishType" type="hidden" value="${project.publishType}">
            <input id="bzjper" type="hidden" value="${project.bzjper}">
            <input id="source" type="hidden" value="${source}">

            <#if  "${project.publishType}"=="001" >
                <div class="release" style="width: 100%;" style="margin-left: 20px;">
                    <ul class="clearfix whitebg">
                        <span style="font-weight: bold">设置实施费用</span>
                        <#if "${project.projectType}"?contains("001")  >
                            <li class="clearfix" style="width: 100%;margin-top: 10px;">
                                <label class="fl" style="width: 100%;">您接受的最低监理实施费用<span class="red">*</span> </label>
                                <input type="text" style="width: 80%;" class="fl" id="jlSsMoney" name="jlSsMoney"
                                       lay-maxlength="30" onblur="_crt_page.events.ssonblur()"   autocomplete="off"
                                       lay-verify="required|maxlength|decimal"><span class="ml10 fl">元</span>
                            </li>
                        </#if>
                        <#if "${project.projectType}"?contains("002")  >
                            <li class="clearfix" style="width: 100%;margin-top: 10px;">
                                <label class="fl" style="width: 100%;">您接受的最低咨询实施费用<span class="red">*</span> </label>
                                <input type="text" class="fl" style="width: 80%;" id="zxSsMoney" name="zxSsMoney"
                                       lay-maxlength="30" onblur="_crt_page.events.ssonblur()"   autocomplete="off"
                                       lay-verify="required|maxlength|decimal"><span class="ml10 fl">元</span>
                            </li>
                        </#if>
                        <#if "${project.projectType}"?contains("003")  >
                            <li class="clearfix" style="width: 100%;margin-top: 10px;">
                                <label class="fl" style="width: 100%;">您接受的最低检测实施费用<span class="red">*</span> </label>
                                <input type="text" class="fl" style="width: 80%;" id="jcSsMoney" name="jcSsMoney"
                                       lay-maxlength="30" onblur="_crt_page.events.ssonblur()"   autocomplete="off"
                                       lay-verify="required|maxlength|decimal"><span class="ml10 fl">元</span>
                            </li>
                        </#if>
                        <#if "${project.projectType}"?contains("100")  >
                            <li class="clearfix" style="width: 100%;margin-top: 10px;">
                                <label class="fl" style="width: 100%;">您接受的最低其他实施费用<span class="red">*</span> </label>
                                <input type="text" class="fl" style="width: 80%;" id="qtSsMoney" name="qtSsMoney"
                                       lay-maxlength="30" onblur="_crt_page.events.ssonblur()"   autocomplete="off"
                                       lay-verify="required|maxlength|decimal"><span class="ml10 fl">元</span>
                            </li>
                        </#if>
                    </ul>
                </div>
            </#if>
            <#if  "${project.publishType}"!="001" >
                <div class="release" style="width: 100%;">
                    <ul class="clearfix whitebg" style="margin-left: 20px;">
                        <#if "${project.projectType}"?contains("001")   >
                            <li class="clearfix" style="width: 100%;margin-top: 10px;">
                                <label class="fl" style="width: 100%;">您接受的最低监理服务费用<span class="red">*</span> </label>
                                <input type="text" style="width: 80%;" class="fl" id="jlFwMoney" name="jlFwMoney"
                                       lay-maxlength="30" onblur="_crt_page.events.fwonblur()"   autocomplete="off"
                                       lay-verify="required|maxlength|decimal"><span class="ml10 fl">元</span>
                            </li>
                        </#if>
                      	<#if "${project.projectType}"?contains("002")  >
                        <li class="clearfix" style="width: 100%;margin-top: 10px;">
                            <label class="fl" style="width: 100%;">您接受的最低咨询服务费用<span class="red">*</span> </label>
                            <input type="text" class="fl" style="width: 80%;" id="zxFwMoney" name="zxFwMoney"
                                   lay-maxlength="30" onblur="_crt_page.events.fwonblur()"   autocomplete="off"
                                   lay-verify="required|maxlength|decimal"><span class="ml10 fl">元</span>
                        </li>
                      	</#if>
                        <#if "${project.projectType}"?contains("003")  >
                            <li class="clearfix" style="width: 100%;margin-top: 10px;">
                                <label class="fl" style="width: 100%;">您接受的最低检测服务费用<span class="red">*</span> </label>
                                <input type="text" class="fl" style="width: 80%;" id="jcFwMoney" name="jcFwMoney"
                                       lay-maxlength="30" onblur="_crt_page.events.fwonblur()"   autocomplete="off"
                                       lay-verify="required|maxlength|decimal"><span class="ml10 fl">元</span>
                            </li>
                        </#if>
                        <#if "${project.projectType}"?contains("100")  >
                            <li class="clearfix" style="width: 100%;margin-top: 10px;">
                                <label class="fl" style="width: 100%;">您接受的最低其他服务费用<span class="red">*</span> </label>
                                <input type="text" class="fl" style="width: 80%;" id="qtFwMoney" name="qtFwMoney"
                                       lay-maxlength="30" onblur="_crt_page.events.fwonblur()"  autocomplete="off"
                                       lay-verify="required|maxlength|decimal"><span class="ml10 fl">元</span>
                            </li>
                        </#if>
                    </ul>
                </div>
            </#if>
            <div style="margin-left: 20px;">
                总额：
                <span style="padding: 2%;" id="totalMoney"></span>元
            </div>
            <div class="releaseBtn center  whitebg">
                <button type="button" class="blue bgnone close">关闭</button>
                <button type="submit" lay-submit lay-filter="save" class="bluebg white ft18" id="btnsave">保存</button>
                </button>
            </div>
        </form>
    </div>
</div>
<!--JQ-->
<!--公用样式JS-->
<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<!--启动JS-->
<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/jquery.boot.js"></script>
<!--启动JS-->
<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/jquery.common.js"></script>
<script type="text/javascript" src="${re.contextPath}/pageoffice.js" id="po_js_main"></script>
<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/supplier/common/js/fileoper.js"></script>
<!-- 公共配置第三方组件 -->
<script type="text/javascript">
    layui.config({
        version: false,
        debug: false,
        base: "${re.contextPath}/plugin/layui/lay/extra/"
    })
</script>

<script>
    var layer, form, laydate, table, autocomplete;
    var _crt_page;
    var _xstjlManagerPerson;
    var _xstzxManagerPerson;
    var _xstjcManagerPerson;
    var _xstqtManagerPerson;

    layui.use(['form', 'laydate', 'layer', 'autocomplete'], function () {
        layer = layui.layer;
        form = layui.form;
        laydate = layui.laydate;

        $('.close').click(function () {
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        });
        form.verify({
            maxlength: function (v, item) {
                var maxlength = item.getAttribute('lay-maxlength');
                if (v.trim() != '') {
                    if (v.trim().length > maxlength) {
                        return "输入长度不能大于" + maxlength + "个字符！";
                    }
                }
            },
            phoneNumber: function (v) {
                if (v.trim() == '') {
                    return '手机号不能为空';
                } else {
                    if (!v.trim().isMobile() && !v.trim().isTel()) {
                        return '请输入正确的手机号码或电话号码\n\n例如:13916752109或0531-3614072';
                    }
                }
            },
            number: function (v) {
                var reg = /^[0-9]*$/;
                var flag = reg.test(v.trim());
                if (!flag) {
                    return '请输入正确的数字';
                }
            },
            decimal: function (v) {
                var reg = /^-?([0-9]+|[0-9]{1,3}(,[0-9]{3})*)(.[0-9]{1,10})?$/;
                var flag = reg.test(v.trim());
                if (!flag) {
                    return '请输入正确的金额';
                }
            },
            perdecimal: function (v) {
                var reg = /^[1-9][0-9]*([.][0-9]+)?$/;
                var flag = reg.test(v.trim());
                if (!flag) {
                    if (v.trim() != "0" || v.trim() != 0) {
                        return '请输入数字';
                    }
                }
            }
        })
        _crt_page = {
            init: function () {
                //初始化事件
                _crt_page.events._init();
                //初始化Form
                form.on('submit(save)', _crt_page.forms.save);
                form.on('submit(submit)', _crt_page.forms.commit);
            },
            forms: {
                save: function (data) {
                    if(data.field.jlFwMoney && Number(data.field.jlFwMoney)<=0){
                        layer.msg('金额不正确', {icon: 2});return false;
                    }
                    if(data.field.zxFwMoney && Number(data.field.zxFwMoney)<=0){
                        layer.msg('金额不正确', {icon: 2});return false;
                    }
                    if(data.field.jcFwMoney && Number(data.field.jcFwMoney)<=0){
                        layer.msg('金额不正确', {icon: 2});return false;
                    }
                    if(data.field.qtFwMoney && Number(data.field.qtFwMoney)<=0){
                        layer.msg('金额不正确', {icon: 2});return false;
                    }
                    if (data.field.jlSsMoney && Number(data.field.jlSsMoney)<=0){
                        layer.msg('金额不正确', {icon: 2});return false;
                    }
                    if(data.field.zxSsMoney && Number(data.field.zxSsMoney)<=0){
                        layer.msg('金额不正确', {icon: 2});return false;
                    }
                    if(data.field.jcSsMoney && Number(data.field.jcSsMoney)<=0){
                        layer.msg('金额不正确', {icon: 2});return false;
                    }
                    if(data.field.qtSsMoney && Number(data.field.qtSsMoney)<=0){
                        layer.msg('金额不正确', {icon: 2});return false;
                    }
                    $('#btnsave').addClass("layui-btn-disabled").attr("disabled", true);
                    var istg = _crt_page.events.saveBefore(data);
                    if (istg) {
                        layerAjax('/supplier/projectManager/saveUpdateAcceptProjectFy', data.field, '', function (d) {
                            if (d.flag == true) {
                                $('#btnsave').addClass("layui-btn-disabled").attr("disabled", true);
                                layer.msg(d.msg, {icon: 1});
                            } else {
                                $('#btnsave').removeClass("layui-btn-disabled").attr("disabled", false);
                                layer.msg(d.msg, {icon: 2});
                            }
                        });
                    } else {
                        $('#btnsave').removeClass("layui-btn-disabled").attr("disabled", false);
                    }
                    return false;
                }

            },
            events: {
                _init: function () {
                    var projectType = "${project.projectType}";
                },
                fwonblur: function () {
                    //填写最低服务费
                    var totalMoney = 0.0;
                    var jlFwMoney = $("#jlFwMoney").val();
                    var zxFwMoney = $("#zxFwMoney").val();
                    var jcFwMoney = $("#jcFwMoney").val();
                    var qtFwMoney = $("#qtFwMoney").val();
                    if (jlFwMoney) {
                        totalMoney = parseFloat(totalMoney) + parseFloat(jlFwMoney)
                    }
                    if (zxFwMoney) {
                        totalMoney = parseFloat(totalMoney) + parseFloat(zxFwMoney)
                    }
                    if (jcFwMoney) {
                        totalMoney = totalMoney + parseFloat(jcFwMoney)
                    }
                    if (qtFwMoney) {
                        totalMoney = totalMoney + parseFloat(qtFwMoney)
                    }
                    $("#totalMoney").html(totalMoney);

                },
                ssonblur: function () {
                    //填写最低服务费

                    var totalMoney = 0.0;
                    var jlFwMoney = $("#jlSsMoney").val();
                    var zxFwMoney = $("#zxSsMoney").val();
                    var jcFwMoney = $("#jcSsMoney").val();
                    var qtFwMoney = $("#qtSsMoney").val();
                    if (jlFwMoney) {
                        totalMoney = parseFloat(totalMoney) + parseFloat(jlFwMoney)
                    }
                    if (zxFwMoney) {
                        totalMoney = parseFloat(totalMoney) + parseFloat(zxFwMoney)
                    }
                    if (jcFwMoney) {
                        totalMoney = totalMoney + parseFloat(jcFwMoney)
                    }
                    if (qtFwMoney) {
                        totalMoney = totalMoney + parseFloat(qtFwMoney)
                    }
                    $("#totalMoney").html(totalMoney);


                },
                saveBefore: function (data) {
                    var isTg = true;
                    var publishType = "${project.publishType}";
                    if ("001" == publishType) {
                        // 内部
                        var totalMoney = 0.0;
                        var jlFwMoney = $("#jlSsMoney").val();
                        var zxFwMoney = $("#zxSsMoney").val();
                        var jcFwMoney = $("#jcSsMoney").val();
                        var qtFwMoney = $("#qtSsMoney").val();
                        if (jlFwMoney) {
                            totalMoney = parseFloat(totalMoney) + parseFloat(jlFwMoney)
                        }
                        if (zxFwMoney) {
                            totalMoney = parseFloat(totalMoney) + parseFloat(zxFwMoney)
                        }
                        if (jcFwMoney) {
                            totalMoney = totalMoney + parseFloat(jcFwMoney)
                        }
                        if (qtFwMoney) {
                            totalMoney = totalMoney + parseFloat(qtFwMoney)
                        }
                        data.field.totalMoney = totalMoney;
                    } else if ("002" == publishType) {
                        var totalMoney = 0.0;
                        var jlFwMoney = $("#jlFwMoney").val();
                        var zxFwMoney = $("#zxFwMoney").val();
                        var jcFwMoney = $("#jcFwMoney").val();
                        var qtFwMoney = $("#qtFwMoney").val();
                        if (jlFwMoney) {
                            totalMoney = parseFloat(totalMoney) + parseFloat(jlFwMoney)
                        }
                        if (zxFwMoney) {
                            totalMoney = parseFloat(totalMoney) + parseFloat(zxFwMoney)
                        }
                        if (jcFwMoney) {
                            totalMoney = totalMoney + parseFloat(jcFwMoney)
                        }
                        if (qtFwMoney) {
                            totalMoney = totalMoney + parseFloat(qtFwMoney)
                        }
                        data.field.totalMoney = totalMoney;

                    }
                    return isTg;

                },

            }
        }
        ;
        _crt_page.init();
    })
    ;


</script>

</body>

</html>